#include<cstdio>
#include<iostream>
using namespace std;

const int MAX_QUEUE_SIZE = 1000;
int qu[MAX_QUEUE_SIZE];
int head = 0,tail = 0;

inline int clear(){
	return head = 0;
}

inline bool is_empty(){
	return head == tail;
}

inline bool is_full(){
	return tail == MAX_QUEUE_SIZE;
}

inline int size(){
	return tail - head;
}

inline void push(int data){
	if(!is_full())	qu[tail++]= data;	
}

inline void pop(){
	if(!is_empty())	head++;
}

inline int get_top(){
	return qu[head];
}

int main(){
	int n,t1,t2;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>t1;
		if(t1 == 1){
			cin>>t2;
			push(t2);
		}else{
			if(is_empty()){
				cout<<"impossible!"<<endl;
				return 0;
			}
			pop();
		}		
	}
	if(is_empty()){
		cout<<"impossible!"<<endl;
	}else{
		cout<<get_top()<<endl;
	}
	return 0;

}
